﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MenusHunter.Core.Helper
{
    public class FoodsHelper
    {
        public static List<Food> GetListFoodRestaurant(int resId)
        {
            var list = new List<Food>();
            var db = new MenusHunterDataContext();
            list = (from f in db.Foods where f.RestaurantId == resId select f).ToList();
            return list;
        }

        public static bool NewFood(Food f)
        {
            using (var db = new MenusHunterDataContext())
            {
                db.Foods.InsertOnSubmit(f);
                return f.Id>0;
            }
        }

        public static bool UpdateFood(Food f)
        {
            using (var db = new MenusHunterDataContext())
            {
                db.Foods.InsertOnSubmit(f);
                db.SubmitChanges();
                return true;
            }
        }

        public static bool DeleteFood(Food f)
        {
            using (var db= new MenusHunterDataContext())
            {
                db.Foods.DeleteOnSubmit(f);
                db.SubmitChanges();
                return true;
            }
        }
    }
}
